Page({

  /**
   * 页面的初始数据
   */
  data: {
    pricesum:0,
    id:0,
    product:[
      {id:1,name:'新季节先知道',hot:'——小光新报道',src:'/static/image/陪3.jpeg',classid:3},
      {id:2,name:'红尘听雨落愿君世..',hot:'预热',src:'/static/image/陪3.jpeg',classid:0},
      {id:3,name:'xingchen陪玩团',hot:'预热',src:'/static/image/陪3.jpeg'  ,classid:3},
      {id:4,name:'HAS陪玩团',hot:'预热',src:'/static/image/陪4.jpeg' ,classid:3},
      {id:5,name:'Hohsino陪玩团',hot:'预热',src:'/static/image/陪5.jpeg',classid:3},
      {id:6,name:'Sky知己NFC功能',hot:'预热',src:'/static/image/陪3.jpeg',classid:2},
      {id:7,name:'2022新款光遇徽',hot:'预热',src:'/static/image/陪3.jpeg',classid:2},
      {id:8,name:'光遇周边新款',hot:'预热',src:'/static/image/陪5.jpeg',classid:1},
      {id:9,name:'光遇周边sk',hot:'预热',src:'/static/image/陪4.jpeg',classid:1},
      {id:10,name:'光遇周边抱',hot:'预热',src:'/static/image/陪5.jpeg',classid:1},
    ],
    productlist:[]

  },
 
    niming:function(e){
      var p = this.data.productlist;
      var id = e.currentTarget.id;
      var pri = 0;
    if (e.detail.value !='') {
      
      this.data.check = 1  
      for(var i=0;i<p.length;i++){
        if(p[i].id == id){
            pri = this.data.pricesum + p[i].price
        }
      }
    }
    
    else {
      for(var i=0;i<p.length;i++){
        if(p[i].id == id){
            pri = this.data.pricesum - p[i].price 
         
        }
      }
    }
    this.setData({
      pricesum:pri
    })
    },
   
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {

    
   
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
   
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var username = wx.getStorageSync('id')

    this.setData({
        id: username
     })
     
    this.setData({
      id:this.data.id.concat(username)
  })
    //  this.productlist.push({product[id]})
    var arr = [];
    console.log(username)

    for(var i=0;i<12;i++){
      if(this.data.product[i].id==username){

        var obj = this.data.product[username];
        arr.push(obj)
      }
    }
    
    this.setData({
      productlist : arr
    })
    console.log(this.data.product)
    console.log(this.data.productlist)
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})